package abstractFactory;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import dao.Card.CardDAO;
import dao.Card.CardDAOJPA;
import dao.Category.CategoryDAO;
import dao.Category.CategoryDAOJPA;
import dao.Client.ClientDAO;
import dao.Client.ClientDAOJPA;
import dao.Item.ItemDAO;
import dao.Item.ItemDAOJPA;
import dao.Product.ProductDAO;
import dao.Product.ProductDAOJPA;
import dao.ProfileType.ProfileTypeDAO;
import dao.ProfileType.ProfileTypeDAOJPA;
import dao.Sale.SaleDAO;
import dao.Sale.SaleDAOJPA;
import dao.User.UserDAO;
import dao.User.UserDAOJPA;

public class FactoryJPA extends Factory{
	static EntityManagerFactory factory;

	public FactoryJPA(){}

	public EntityManagerFactory createFactory(){
		if(factory == null){
			factory = Persistence.createEntityManagerFactory("Loja2");
			return factory;
		}
		return  factory;
	}

	public CardDAO createCardDAO() {
		return new CardDAOJPA();
	}

	public ClientDAO createClientDAO() {
		return new ClientDAOJPA();
	}

	public CategoryDAO createCategoryDAO() {
		return new CategoryDAOJPA();
	}

	public ProductDAO createProductDAO() {
		return new ProductDAOJPA();
	}

	public UserDAO createUserDAO() {
		return new UserDAOJPA();
	}

	public SaleDAO createSaleDAO() {
		return new SaleDAOJPA();
	}

	public ItemDAO createItemDAO(){
		return new ItemDAOJPA();
	}

	public ProfileTypeDAO createProfileTypeDAO() {
		return new ProfileTypeDAOJPA();
	}
}